#!/bin/bash

# Description:
#	operations about file name, add suffix, remove the extension names

show_help () {
	echo "	"
	echo "my-suffix.sh [-h|-a|-r]: operation about file names"
	echo "---------------------------------------------------"
	echo "-a	add suffix into filename, keep extension name"
	echo "	my-suffix.sh -a <filename> <suffix>"
	echo "	for example:"
	echo "		original name: input.nc"
	echo "		modified name: input-<suffix>.nc"
	echo "-r	remove extension names"
	echo "	my-suffix -r <filename>"
	echo "	for example:"
	echo "		original name: input.nc"
	echo "		output: 	   input"
	echo ""
}

remove_extension () {
	echo ${1%\.*}
}

add_suffix () {
	echo "${1%\.*}-${2}.${1##*\.}"
}

case $1 in 
	-h )
		show_help;;
	-r )
		remove_extension $2;;
	-a )
		add_suffix $2 $3 ;;
	* )
		show_help;;
esac

